package com.h5ve.flow.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.h5ve.flow.mapper.WarmFlowMapper;
import com.h5ve.flow.service.ExecuteService;
import com.h5ve.flow.vo.FlowTaskVo;
import com.h5ve.system.entity.User;
import org.dromara.warm.flow.core.entity.HisTask;
import org.dromara.warm.flow.core.entity.Task;
import org.dromara.warm.flow.orm.entity.FlowHisTask;
import org.dromara.warm.flow.orm.entity.FlowTask;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
 * @author warm
 * @description: 流程执行serviceImpl
 * @date: 2023/5/29 13:09
 */
@Service
public class ExecuteServiceImpl implements ExecuteService {

    @Resource
    private WarmFlowMapper flowMapper;

    @Override
    public Page<FlowTaskVo> toDoPage(Page<FlowTaskVo> page, Task task) {
        return page.setRecords(flowMapper.toDoPage(task));
    }

    @Override
    public Page<FlowHisTask> donePage(Page<FlowHisTask> page, HisTask hisTask) {
        return page.setRecords(flowMapper.donePage(hisTask));
    }

    @Override
    public Page<FlowHisTask> copyPage(Page<FlowHisTask> page, FlowTask flowTask) {
        return page.setRecords(flowMapper.copyPage(flowTask));
    }

    /**
     * 根据ID反显姓名
     *
     * @param ids 需要反显姓名的用户ID
     * @return {@link List <User>}
     * @author liangli
     * @date 2024/8/21 17:11
     **/
    @Override
    public List<User> idReverseDisplayName(Long[] ids) {
        if (Objects.isNull(ids) || ids.length == 0) {
            return null;
        }
        return flowMapper.idReverseDisplayName(ids);
    }
}
